create PROCEDURE spContract_SetClear
(
	@ContractId int
)
AS
BEGIN
	set nocount on
	set xact_abort on
		
	declare @ContactId int, @PackageId int, @TravelId int
	
	select @ContactId = ContactId, @PackageId = PackageId
	from [Contract] (nolock)
	where ContractId = @ContractId
	
	select @TravelId = TravelId
	from ClientPackage (nolock)
	where ClientId = @ContactId
		and PackageId = @PackageId
	
	begin transaction
		delete
		from ClientPackageChoice
		where TravelId = @TravelId
	
		update ClientPackage
		set [Status] = 'AVAILABLE', 
			PkgDestId = NULL
		where TravelId = @TravelId
	commit transaction
END